<template>
  <h2>Child组件</h2>
  <h3>{{ age }}</h3>
  <button @click="postMsg">触发context</button>
</template>

<script>
export default {
  props: {
    age: Number,
  },
  emits: ["setAge"],
  setup(props, context) {
    console.log(props, context);
    function postMsg() {
      console.log("我发送了");
      context.emit("setAge");
    }
    context.emit("setAge");

    return {
      ...props,
      postMsg,
    };
  },
};
</script>

<style>
</style>